Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Disable and enable extensions #11184

Merged
merged 11 commits into from
Jul 8, 2015
Merged

Disable and enable extensions #11184

merged 11 commits into from
Jul 8, 2015

Conversation

busykai
Copy link
Contributor

@busykai busykai commented May 30, 2015

This PR provides a simple mechanism to disable and enable again an extension and complete support of the functionality in the Extension Manager.

Extension loader looks for .disabled file in the extension directory, if it's present the information is included and propagated to the entire extensibility subsystem. Extension Manager can disable and enable extensions using the same mechanism.

Extension can also be disabled using `"disable": true` in the package.json.

Details:
    - Rename getPackageJson to getMetadata.
    - Check for presence of .disabled file in the extension directory and add
      it to the metadata.
    - Do not load extension if it is disabled instead, reject with disabled
      status.
    - Add DISABLED extension state.
    - Extension is still gets on record and is enumerated with all its
      metadata, but it's not started.
@busykai busykai force-pushed the kai/disable-enable-extensions branch from 3d92fdb to 9784ba2 Compare May 30, 2015 23:46
@busykai busykai force-pushed the kai/disable-enable-extensions branch from 9784ba2 to c8af09f Compare May 31, 2015 00:01
@busykai
Copy link
Contributor Author

busykai commented May 31, 2015

CC: @albertinad, you made me do it. now you have to review it. :)

"MARKED_FOR_REMOVAL" : "Marked for removal",
"UNDO_REMOVE" : "Undo",
"MARKED_FOR_UPDATE" : "Marked for update",
"UNDO_UPDATE" : "Undo",
"MARKED_FOR_DISABLING" : "Marked for disabling",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not keen on this phrase. Perhaps Marked as disabled would be more appropriate. It doesn't have to follow the semantics of removal and update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it either, so we could probably come with something better. Marked as disabled is not good because it implies a completed action. Marked to be disabled, perhaps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it does. Since it is not disabled until the dialog closes, so is not true that it is "Marked as disabled".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are thinking that the user knows of the implementation. According to the UI, I hit the disable button and now it is Marked as Disabled. This is further backed by the fact that there is an undo link... meaning I am undoing the action of marking as disabled. The user has no idea (or should they) when the actual file gets written to disk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomMalbran is right. User has to be aware anyways: after extension manager is dismissed, there will be a dialog asking for confirmation and if canceled all extensions marked will be unmarked (and left intact).

So what about Marked to be disabled vs Marked for disabling? With all the context, do we need to change it in the first place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither one is English, so it doesn't matter.

You are focusing too much on the disabled part. The action you are taking in the UI is marking and once you click on disable it is marked.

... but choose whatever you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label appears when the action of marking has been taken, so marked is totally appropriate. OK, I will leave it as is for now.

@mackenza
Copy link
Contributor

Good stuff. As I mentioned on Slack, I think the .disabled file is a great, simple way of using convention over configuration to make this work. So I definately appreciate that.

Unless I am missing something, or maybe behaviour is different on Linux (Ubuntu 14.04 x64 here), but I don't see how you can enable a disabled extension. I was expecting an Enable button in my "Installed" list in Extension Manager.

@busykai
Copy link
Contributor Author

busykai commented May 31, 2015

Unless I am missing something, or maybe behaviour is different on Linux (Ubuntu 14.04 x64 here), but I don't see how you can enable a disabled extension. I was expecting an Enable button in my "Installed" list in Extension Manager.

This sounds as a bug. Checked, it should be Enable. Somehow it regressed while I was writing tests. :( Will fix.

@mackenza
Copy link
Contributor

My disabled extensions show up in the list, but the buttons all say Disable

@busykai
Copy link
Contributor Author

busykai commented May 31, 2015

@mackenza, fixed it (slightly blushing).

ExtensionLoader.loadExtension(FileUtils.getBaseName(path), { baseUrl: path }, "main")
.done(result.resolve)
.fail(result.reject);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to return the promise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Fixed.

@TomMalbran
Copy link
Contributor

You need to unmark all extensions that were marked to be disabled after this line (https://github.com/adobe/brackets/blob/kai/disable-enable-extensions/src/extensibility/ExtensionManagerDialog.js#L209).

})
.fail(function (errorArray) {
dlg.close();
ExtensionManager.cleanupUpdates();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you still need line after if (removeErrors) { ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think so. Updates are done always (in parallel) with this change independently of how it went for removes. The only place it needs to be done is when the entire confirmation is cancelled.

@zaggino
Copy link
Contributor

zaggino commented May 31, 2015

question: will this work for default extensions? if so, can we add .disabled to .gitignore file?

@busykai
Copy link
Contributor Author

busykai commented May 31, 2015

@zaggino, it will work on default extensions via manually creating and deleting .disabled file.

@TomMalbran, thanks for the thorough review will fix these.

@mackenza
Copy link
Contributor

@zaggino @busykai I went into /src/extensions/default/CodeFolding, did a touch .disabled and reloaded Brackets and, indeed, no code folding.

removeExtensionsPromise = ExtensionManager.removeMarkedExtensions();
removeExtensionsPromise
.fail(function (errorArray) {
removeErrors = errorArray;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the code might look better if you parsed the error array here and created the dialog, instead of doing it in the general fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to create dialogs at this scope. The error condition is processed in the .fail of the consolidated promise (Async.waitForAll).

@zaggino
Copy link
Contributor

zaggino commented May 31, 2015

@busykai great, can you add an .disabled entry to the https://github.com/adobe/brackets/blob/master/.gitignore then?

@busykai
Copy link
Contributor Author

busykai commented Jun 1, 2015

@zaggino, you're right. Will add this file to .gitignore.

busykai added 3 commits May 31, 2015 22:24
It could be used to disable default extensions and must never be committed.
Async.waitForAll would not fail, unless failOnReject argument is true.
@busykai
Copy link
Contributor Author

busykai commented Jun 1, 2015

Did some more testing, focused on error handling. Seems to be fine now.

@@ -34,3 +34,6 @@ Thumbs.db

# Files that can be automatically downloaded that we don't want to ship with our builds
/src/extensibility/node/node_modules/request/tests/

# .disabled should be ignored, it could be used to disable default extensions
.disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be more specific: src/extensions/default/*/.disabled

We may also use this file in unit tests for this feature, and in this case it should be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's an overkill. It clearly says default extensions there's nothing to misunderstand.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In installer builds, "src" is "www". Don't you want to handle both? (referring to line above, not this one)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need a .gitignore in installer builds? It's not like the www is a git repo...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelgerber, actually I misunderstood you, you were saying the rule itself should be more specific and I understood you were referring to the comment text. Will fix this.

@rroshan1
Copy link
Contributor

@larz0 @busykai I was thinking of something like this- Update button if applicable should be on a separate line while the disable and remove buttons should be consistent.. Since mostly there won't be many update buttons, the right side won't seem to be heavy either. What do you guys think?
extensions2

@larz0
Copy link
Member

larz0 commented Jun 23, 2015

@rroshan1 that works too! We shouldn't be getting more buttons in that area (fingers crossed) so let's go with that 👍

@nethip
Copy link
Contributor

nethip commented Jun 23, 2015

@larz0 Thanks!.

@busykai Please go ahead with the suggested changes to this PR, so that it can be merged. Let us target this for 1.4.

@abose abose added this to the Release 1.4 milestone Jun 23, 2015
@busykai
Copy link
Contributor Author

busykai commented Jun 25, 2015

@rroshan1, simplicity is the best! :) I should have thought about this layout!..

@busykai
Copy link
Contributor Author

busykai commented Jun 25, 2015

@rroshan1, @larz0 how about this? made the buttons a little bit more spread:
screen shot 2015-06-25 at 11 25 01
or little less spread:
screen shot 2015-06-25 at 11 27 45
I like the second better.

@abose
Copy link
Contributor

abose commented Jun 25, 2015

I like the first one better. The second one seems a bit out of proportion to me.

@lenovouser
Copy link

@busykai I think the first one looks better. The second one seems so cluttered.

@busykai
Copy link
Contributor Author

busykai commented Jun 25, 2015

OK. FWIW, the second one is what close to what we used to have (buttons are close to each other).

Added margin of 3px to any extension action button (more spread buttons).
@busykai busykai force-pushed the kai/disable-enable-extensions branch from 398df58 to 03b1e44 Compare June 25, 2015 14:48
@busykai
Copy link
Contributor Author

busykai commented Jun 25, 2015

@rroshan1, ready for re-review. did not address separate functions comment though. let me know if you feel it has to be addressed.

@mackenza
Copy link
Contributor

@busykai agreed 1st screenshot is much better than 2. Even if 2 is what we have now.

side note: why is remove greyed out on "Proper Indent" extension in both SS?

@busykai
Copy link
Contributor Author

busykai commented Jun 25, 2015

@mackenza, it's in src/extensions/dev (space to develop extensions) -- they are not managed via this dialog (but you still should be able to disable your extension if you screwed up :).

EDIT: I've pushed the first version, so more spacious design with this change.

@larz0
Copy link
Member

larz0 commented Jun 26, 2015

@busykai great, first screenshot is better but could we shave off 2px to the spacing between Disable and Remove buttons?

@busykai
Copy link
Contributor Author

busykai commented Jun 26, 2015

@larz0, like this?
screen shot 2015-06-26 at 11 23 04

Remove right margin entirely.
@busykai
Copy link
Contributor Author

busykai commented Jun 29, 2015

@larz0, so I've pushed the changes to the layout corresponding to the last image.

@rroshan1, this is ready for review.

@larz0
Copy link
Member

larz0 commented Jun 30, 2015

@busykai looks good here 👍

@rroshan1
Copy link
Contributor

Thanks @busykai .. 👍
I will get back soon after doing some testing and review.

@busykai
Copy link
Contributor Author

busykai commented Jul 7, 2015

@rroshan1, now fully compliant to the comments.

@rroshan1
Copy link
Contributor

rroshan1 commented Jul 8, 2015

Thanks @busykai..
I have run unit tests and scenario testings from my side and everything looks good and smooth.
Merging it.

rroshan1 added a commit that referenced this pull request Jul 8, 2015
@rroshan1 rroshan1 merged commit 2501136 into master Jul 8, 2015
@busykai busykai deleted the kai/disable-enable-extensions branch July 8, 2015 14:31
sprintr pushed a commit to sprintr/brackets that referenced this pull request Jul 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.